import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class MarkGui extends JFrame implements ActionListener
{
	//Singleton
	
	private Student student;
	private Course course;
	
	private static MarkGui mg=null;
	
	JButton  btnAdd,btnClear,btnExit;
	JLabel lblHeading,lblStudentNo,lblStudentNoVal,lblStudentName,lblStudentNameVal,lblCourseNo,lblCourseNoVal,lblCourseName,lblCourseNameVal,lblEmpty,lblEmpty2;
	
	JLabel lblMarkNormal,lblMarkRepeat;
	
	//JTextField txtStudentNo;		
	
	//Core/Optional Coursses
	JLabel lblAssignment1,lblAssignment2,lblAssignment3,lblClassTest,lblFinalPaperl,lblPractical;
	JTextField txtAssignment1,txtAssignment2,txtAssignment3,txtClassTest,txtFinalPaperl,txtPractical;
	
	//Repeat
	JLabel lblAssignment1R,lblAssignment2R,lblAssignment3R,lblClassTestR,lblFinalPaperlR,lblPracticalR;
	JTextField txtAssignment1R,txtAssignment2R,txtAssignment3R,txtClassTestR,txtFinalPaperlR,txtPracticalR;
	
	//Project
	JLabel lblProjectIReport,lblProjectIPresentation,lblProjectFReport,lblProjectFPresentation,lblProjectFProd;
	JTextField txtProjectIReport,txtProjectIPresentation,txtProjectFReport,txtProjectFPresentation,txtProjectFProd;
	
	JLabel lblProjectIReportR,lblProjectIPresentationR,lblProjectFReportR,lblProjectFPresentationR,lblProjectFProdR;
	JTextField txtProjectIReportR,txtProjectIPresentationR,txtProjectFReportR,txtProjectFPresentationR,txtProjectFProdR;
	
	//JPanels
	JPanel screenSub,screenMain;
	
	private MarkGui(Enroll e)
	{
		//Disables parent form's buttons
		MarksOperations.getInstance().toggleAllButtonsStatus(false);
		
		student=XmlOperations.getInstance().searchStudentByNo(Integer.toString(e.getNo()));
		course=XmlOperations.getInstance().searchCourseByNo(Integer.toString(e.getCode()));
		
		//Outer Panel
		screenMain= (JPanel)getContentPane( );
		screenMain.setLayout( new BorderLayout() );		
		screenMain.setBorder(new EmptyBorder(10, 10, 10, 10));
		//
		
		//Inner Panel
		screenSub=new JPanel( );
		
		switch(course.getType())
		{
			case CORE:
				if(course.getHasPracticals())
				{
					screenSub.setLayout( new GridLayout( 20,0,8,8 ));	
				}
				else
				{
					screenSub.setLayout( new GridLayout( 18,0,8,8 ));	
				}					
			break;
			case OPTIONAL:
				if(course.getHasPracticals())
				{
					screenSub.setLayout( new GridLayout( 18,0,8,8 ));	
				}
				else
				{
					screenSub.setLayout( new GridLayout( 16,0,8,8 ));	
				}			
			break;
			case PROJECT:
				screenSub.setLayout( new GridLayout( 18,0,8,8 ));	
			break;						
		}		
		//

		//Labels
		//Heading
		lblHeading=new JLabel(ProgramUitl.UPDATE_STUDENT_MARKS_TEXT);
		Font fontHeading=new Font(ProgramUitl.FONT_NAME,
									ProgramUitl.HEADING_FONT_STLYE,
									ProgramUitl.HEADING_FONT_SIZE);
		lblHeading.setFont(fontHeading);
		screenMain.add("North",lblHeading);		
		//
		Font fontLbl=new Font(ProgramUitl.FONT_NAME,
									ProgramUitl.NORMAL_FONT_STLYE,
									ProgramUitl.NORMAL_FONT_SIZE);
		lblEmpty=new JLabel(ProgramUitl.EMPTY);						
		lblEmpty.setFont(fontLbl);
		lblEmpty2=new JLabel(ProgramUitl.EMPTY);						
		lblEmpty2.setFont(fontLbl);
		
		
									
		//Student Info
		lblStudentNo=new JLabel(ProgramUitl.STUDNET_NO_TEXT);						
		lblStudentNo.setFont(fontLbl);
		
		lblStudentNoVal=new JLabel(Integer.toString(student.getNo()));						
		lblStudentNoVal.setFont(fontLbl);
			
		lblStudentName=new JLabel(ProgramUitl.STUDNET_NAME_TEXT);						
		lblStudentName.setFont(fontLbl);
		
		lblStudentNameVal=new JLabel(student.getName());						
		lblStudentNameVal.setFont(fontLbl);	
		//
		
		//Course Info
		lblCourseNo=new JLabel(ProgramUitl.COURSE_CODE_TEXT);						
		lblCourseNo.setFont(fontLbl);
			
		lblCourseNoVal=new JLabel(Integer.toString(course.getCode()));						
		lblCourseNoVal.setFont(fontLbl);
		
		lblCourseName=new JLabel(ProgramUitl.COURSE_NAME_TEXT);						
		lblCourseName.setFont(fontLbl);	
		
		lblCourseNameVal=new JLabel(course.getName());						
		lblCourseNameVal.setFont(fontLbl);
		//
		//
		
		//Buttons
		btnAdd=new JButton(ProgramUitl.ADD_TEXT);		
		btnClear=new JButton(ProgramUitl.CLEAR_TEXT);
		btnExit=new JButton(ProgramUitl.EXIT_TEXT,ProgramUitl.getButtonIcon(ProgramUitl.ICON_TYPE.ERROR));
		
		
		btnAdd.addActionListener(this);
		btnClear.addActionListener(this);		
		btnExit.addActionListener(this);
		//	

		//Layout Design
		screenSub.add(lblStudentNo);
		screenSub.add(lblStudentNoVal);
		
		screenSub.add(lblStudentName);
		screenSub.add(lblStudentNameVal);
		
		
		screenSub.add(lblCourseNo);
		screenSub.add(lblCourseNoVal);						
		
		screenSub.add(lblCourseName);
		screenSub.add(lblCourseNameVal);	
		
		//Load the required mark interface
		genMarkGui(course,screenSub,e);
		//
		
		screenSub.add(btnAdd);		
		screenSub.add(btnClear);		
		screenSub.add(btnExit);		
		//
		//Inner panel added to Outer Panel 
		screenMain.add("Center",screenSub);
		//
		
		//Frame Settings
		addWindowListener(new WindowListener() {			
			public void windowClosing(WindowEvent e){}
			public void windowOpened(WindowEvent e) 
			{
				MainMenu.getInstance().setVisible(false);
				MainMenu.getInstance().setEnabled(false);
			}			       
			public void windowClosed(WindowEvent e) {}
			public void windowIconified(WindowEvent e) {}
			public void windowDeiconified(WindowEvent e) {}
			public void windowActivated(WindowEvent e) {}
			public void windowDeactivated(WindowEvent e) {}
		});

		
		setSize(ProgramUitl.SMALL_SCREEN_WIDTH,ProgramUitl.MEDIUM_SCREEN_2_HEIGHT);
		setLocation(ProgramUitl.SCREEN_LOCATION_TOP,ProgramUitl.SCREEN_LOCATION_LEFT);
		setLocationRelativeTo(null);
		setTitle(ProgramUitl.HEADNING_TEXT);		
        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);		
		setUndecorated(true);			
		setVisible(true);
		
		validate();
		//
	}
		
	public static MarkGui getInstance(Enroll e)
	{
		if(mg==null)
		{
			mg=new MarkGui(e);
		}
		
		return mg;
	}	
	//	
	
	//Methods
	void genMarkGui(Course c,JPanel jpCore,Enroll e)
	{		
		Font fontLbl=new Font(ProgramUitl.FONT_NAME,
									ProgramUitl.NORMAL_FONT_STLYE,
									ProgramUitl.NORMAL_FONT_SIZE);
																
		lblMarkNormal=new JLabel(ProgramUitl.MARK_NORMAL_TEXT);						
		lblMarkNormal.setFont(fontLbl);
		lblMarkNormal.setOpaque(true);
		lblMarkNormal.setBackground(Color.lightGray);
		
		lblMarkRepeat=new JLabel(ProgramUitl.MARK_REPEAT_TEXT);						
		lblMarkRepeat.setFont(fontLbl);
		lblMarkRepeat.setFont(fontLbl);
		lblMarkRepeat.setOpaque(true);
		lblMarkRepeat.setBackground(Color.lightGray);	
		
		lblAssignment1=new JLabel(ProgramUitl.MARK_ASSIGN_1_TEXT);						
		lblAssignment1.setFont(fontLbl);
		
		lblAssignment2=new JLabel(ProgramUitl.MARK_ASSIGN_2_TEXT);						
		lblAssignment2.setFont(fontLbl);
		
		lblAssignment3=new JLabel(ProgramUitl.MARK_ASSIGN_3_TEXT);						
		lblAssignment3.setFont(fontLbl);
		
		lblClassTest=new JLabel(ProgramUitl.MARK_CLASS_TEST_TEXT);						
		lblClassTest.setFont(fontLbl);
		
		lblFinalPaperl=new JLabel(ProgramUitl.MARK_FINAL_PAPER_TEXT);						
		lblFinalPaperl.setFont(fontLbl);
		
		lblPractical=new JLabel(ProgramUitl.MARK_PRACTICAL_TEXT);						
		lblPractical.setFont(fontLbl);	
		
		//Rpeat
		
		lblAssignment1R=new JLabel(ProgramUitl.MARK_ASSIGN_1_TEXT);						
		lblAssignment1R.setFont(fontLbl);
		
		lblAssignment2R=new JLabel(ProgramUitl.MARK_ASSIGN_2_TEXT);						
		lblAssignment2R.setFont(fontLbl);
		
		lblAssignment3R=new JLabel(ProgramUitl.MARK_ASSIGN_3_TEXT);						
		lblAssignment3R.setFont(fontLbl);
		
		lblClassTestR=new JLabel(ProgramUitl.MARK_CLASS_TEST_TEXT);						
		lblClassTestR.setFont(fontLbl);
		
		lblFinalPaperlR=new JLabel(ProgramUitl.MARK_FINAL_PAPER_TEXT);						
		lblFinalPaperlR.setFont(fontLbl);
		
		lblPracticalR=new JLabel(ProgramUitl.MARK_PRACTICAL_TEXT);						
		lblPracticalR.setFont(fontLbl);			
		//

		//Project
		lblProjectIReport=new JLabel(ProgramUitl.MARK_PROJECT_INTERIM_REPORT_TEXT);						
		lblProjectIReport.setFont(fontLbl);	

		lblProjectIPresentation=new JLabel(ProgramUitl.MARK_PROJECT_INTERIM_PRESENTATION_TEXT);						
		lblProjectIPresentation.setFont(fontLbl);
		
		lblProjectFReport=new JLabel(ProgramUitl.MARK_PROJECT_FINAL_REPORT_TEXT);						
		lblProjectFReport.setFont(fontLbl);

		lblProjectFPresentation=new JLabel(ProgramUitl.MARK_PROJECT_FINAL_PRESENTATION_TEXT);						
		lblProjectFPresentation.setFont(fontLbl);

		lblProjectFProd=new JLabel(ProgramUitl.MARK_PROJECT_FINAL_PRODUCT_TEXT);						
		lblProjectFProd.setFont(fontLbl);

		//Repeat
		lblProjectIReportR=new JLabel(ProgramUitl.MARK_PROJECT_INTERIM_REPORT_TEXT);						
		lblProjectIReportR.setFont(fontLbl);	

		lblProjectIPresentationR=new JLabel(ProgramUitl.MARK_PROJECT_INTERIM_PRESENTATION_TEXT);						
		lblProjectIPresentationR.setFont(fontLbl);
		
		lblProjectFReportR=new JLabel(ProgramUitl.MARK_PROJECT_FINAL_REPORT_TEXT);						
		lblProjectFReportR.setFont(fontLbl);

		lblProjectFPresentationR=new JLabel(ProgramUitl.MARK_PROJECT_FINAL_PRESENTATION_TEXT);						
		lblProjectFPresentationR.setFont(fontLbl);

		lblProjectFProdR=new JLabel(ProgramUitl.MARK_PROJECT_FINAL_PRODUCT_TEXT);						
		lblProjectFProdR.setFont(fontLbl);		
		//
		
		//
		//
						
		//Text Boxes
		txtAssignment1=new JTextField();		
		txtAssignment2=new JTextField();		
		txtAssignment3=new JTextField();		
		txtClassTest=new JTextField();		
		txtFinalPaperl=new JTextField();		
		txtPractical=new JTextField();	
		
		//Repeat
		txtAssignment1R=new JTextField();		
		txtAssignment2R=new JTextField();		
		txtAssignment3R=new JTextField();		
		txtClassTestR=new JTextField();		
		txtFinalPaperlR=new JTextField();		
		txtPracticalR=new JTextField();		
		//
		
		//Project
		txtProjectIReport=new JTextField();		
		txtProjectIPresentation=new JTextField();		
		txtProjectFReport=new JTextField();		
		txtProjectFPresentation=new JTextField();		
		txtProjectFProd=new JTextField();
		
		//Repeat
		txtProjectIReportR=new JTextField();		
		txtProjectIPresentationR=new JTextField();		
		txtProjectFReportR=new JTextField();		
		txtProjectFPresentationR=new JTextField();		
		txtProjectFProdR=new JTextField();		
		//
		
		//
		
		//Desing the Layout

		switch(course.getType())
		{
			case CORE:
				jpCore.add(lblMarkNormal);
				jpCore.add(lblEmpty);
				
				jpCore.add(lblAssignment1);
				jpCore.add(txtAssignment1);

				jpCore.add(lblAssignment2);
				jpCore.add(txtAssignment2);

				jpCore.add(lblAssignment3);
				jpCore.add(txtAssignment3);
				
				jpCore.add(lblClassTest);
				jpCore.add(txtClassTest);
				
				if(c.getHasPracticals())
				{
					jpCore.add(lblPractical);
					jpCore.add(txtPractical);		
				}				
		
				jpCore.add(lblFinalPaperl);
				jpCore.add(txtFinalPaperl);

				txtAssignment1.setText(Integer.toString(e.getMarksAssignment1()));
				txtAssignment2.setText(Integer.toString(e.getMarksAssignment2()));
				txtAssignment3.setText(Integer.toString(e.getMarksAssignment3()));
				txtClassTest.setText(Integer.toString(e.getMarksClassTest()));
				txtPractical.setText(Integer.toString(e.getMarksPractical()));
				txtFinalPaperl.setText(Integer.toString(e.getMarksFinalPaper()));				
				
				//Repeat
				jpCore.add(lblMarkRepeat);
				jpCore.add(lblEmpty2);
				
				jpCore.add(lblAssignment1R);
				jpCore.add(txtAssignment1R);

				jpCore.add(lblAssignment2R);
				jpCore.add(txtAssignment2R);

				jpCore.add(lblAssignment3R);
				jpCore.add(txtAssignment3R);
				
				jpCore.add(lblClassTestR);
				jpCore.add(txtClassTestR);
				
				if(c.getHasPracticals())
				{
					jpCore.add(lblPracticalR);
					jpCore.add(txtPracticalR);		
				}				
		
				jpCore.add(lblFinalPaperlR);
				jpCore.add(txtFinalPaperlR);	

				txtAssignment1R.setText(Integer.toString(e.getMarksAssignment1Repeat()));
				txtAssignment2R.setText(Integer.toString(e.getMarksAssignment2Repeat()));
				txtAssignment3R.setText(Integer.toString(e.getMarksAssignment3Repeat()));
				txtClassTestR.setText(Integer.toString(e.getMarksClassTestRepeat()));
				txtPracticalR.setText(Integer.toString(e.getMarksPracticalRepeat()));
				txtFinalPaperlR.setText(Integer.toString(e.getMarksFinalPaperRepeat()));	
				
				//
			break;
			case OPTIONAL:
				jpCore.add(lblMarkNormal);
				jpCore.add(lblEmpty);
				
				jpCore.add(lblAssignment1);
				jpCore.add(txtAssignment1);

				jpCore.add(lblAssignment2);
				jpCore.add(txtAssignment2);
				
				jpCore.add(lblClassTest);
				jpCore.add(txtClassTest);
				
				if(c.getHasPracticals())
				{
					jpCore.add(lblPractical);
					jpCore.add(txtPractical);		
				}				
		
				jpCore.add(lblFinalPaperl);
				jpCore.add(txtFinalPaperl);		
				
				txtAssignment1.setText(Integer.toString(e.getMarksAssignment1()));
				txtAssignment2.setText(Integer.toString(e.getMarksAssignment2()));				
				txtClassTest.setText(Integer.toString(e.getMarksClassTest()));
				txtPractical.setText(Integer.toString(e.getMarksPractical()));
				txtFinalPaperl.setText(Integer.toString(e.getMarksFinalPaper()));				
				
				//Rpeat
				jpCore.add(lblMarkRepeat);
				jpCore.add(lblEmpty2);
				
				jpCore.add(lblAssignment1R);
				jpCore.add(txtAssignment1R);

				jpCore.add(lblAssignment2R);
				jpCore.add(txtAssignment2R);
				
				jpCore.add(lblClassTestR);
				jpCore.add(txtClassTestR);
				
				if(c.getHasPracticals())
				{
					jpCore.add(lblPracticalR);
					jpCore.add(txtPracticalR);		
				}				
		
				jpCore.add(lblFinalPaperlR);
				jpCore.add(txtFinalPaperlR);
				
				txtAssignment1R.setText(Integer.toString(e.getMarksAssignment1Repeat()));
				txtAssignment2R.setText(Integer.toString(e.getMarksAssignment2Repeat()));				
				txtClassTestR.setText(Integer.toString(e.getMarksClassTestRepeat()));
				txtPracticalR.setText(Integer.toString(e.getMarksPracticalRepeat()));
				txtFinalPaperlR.setText(Integer.toString(e.getMarksFinalPaperRepeat()));				
				//				
			break;
			case PROJECT:
				jpCore.add(lblMarkNormal);
				jpCore.add(lblEmpty);
				
				jpCore.add(lblProjectIReport);
				jpCore.add(txtProjectIReport);

				jpCore.add(lblProjectIPresentation);
				jpCore.add(txtProjectIPresentation);
				
				jpCore.add(lblProjectFReport);
				jpCore.add(txtProjectFReport);
				
				jpCore.add(lblProjectFPresentation);
				jpCore.add(txtProjectFPresentation);
				
				jpCore.add(lblProjectFProd);
				jpCore.add(txtProjectFProd);	

				txtProjectIReport.setText(Integer.toString(e.getMarksInterimReport()));
				txtProjectIPresentation.setText(Integer.toString(e.getMarksInterimPresentation()));				
				txtProjectFReport.setText(Integer.toString(e.getMarksFinalReport()));
				txtProjectFPresentation.setText(Integer.toString(e.getMarksFinalPresentation()));
				txtProjectFProd.setText(Integer.toString(e.getMarksFinalProduct()));
				
				
				//Repeat
				jpCore.add(lblMarkRepeat);
				jpCore.add(lblEmpty2);
				
				jpCore.add(lblProjectIReportR);
				jpCore.add(txtProjectIReportR);

				jpCore.add(lblProjectIPresentationR);
				jpCore.add(txtProjectIPresentationR);
				
				jpCore.add(lblProjectFReportR);
				jpCore.add(txtProjectFReportR);
				
				jpCore.add(lblProjectFPresentationR);
				jpCore.add(txtProjectFPresentationR);
				
				jpCore.add(lblProjectFProdR);
				jpCore.add(txtProjectFProdR);

				txtProjectIReportR.setText(Integer.toString(e.getMarksInterimReportRepeat()));
				txtProjectIPresentationR.setText(Integer.toString(e.getMarksInterimPresentationRepeat()));				
				txtProjectFReportR.setText(Integer.toString(e.getMarksFinalReportRepeat()));
				txtProjectFPresentationR.setText(Integer.toString(e.getMarksFinalPresentationRepeat()));
				txtProjectFProdR.setText(Integer.toString(e.getMarksFinalProductRepeat()));
				
				//
			break;			
		}

		//		
	}
	
	void exit() 
	{ 		
		int confirmed = JOptionPane.showConfirmDialog(null, 
				ProgramUitl.EXIT_PRORAM_MSG, ProgramUitl.UPDATE_STUDENT_MARKS_TEXT, 
				JOptionPane.YES_NO_OPTION); 
				
		if (confirmed == JOptionPane.YES_OPTION) 
		{        
				MarksOperations.getInstance().toggleAllButtonsStatus(true);				
				mg=null;
				this.dispose();
				
		} 
	}	
	
	void addMarks()
	{
		if(isValidInputs(course))
		{
			if(Confirmation( ProgramUitl.MARKS_CONFRIM_TO_ADD_TEXT))
			{
				Enroll e=new Enroll();
				e.setNo(student.getNo());
				e.setCode(course.getCode());
					
				switch(course.getType())
				{
					case CORE:
						e.setMarksAssignment1(Integer.parseInt(txtAssignment1.getText().trim()));
						e.setMarksAssignment1Repeat(Integer.parseInt(txtAssignment1R.getText().trim()));
						
						e.setMarksAssignment2(Integer.parseInt(txtAssignment2.getText().trim()));
						e.setMarksAssignment2Repeat(Integer.parseInt(txtAssignment2R.getText().trim()));
						
						e.setMarksAssignment3(Integer.parseInt(txtAssignment3.getText().trim()));
						e.setMarksAssignment3Repeat(Integer.parseInt(txtAssignment3R.getText().trim()));
						
						e.setMarksClassTest(Integer.parseInt(txtClassTest.getText().trim()));
						e.setMarksClassTestRepeat(Integer.parseInt(txtClassTestR.getText().trim()));
						
						e.setMarksFinalPaper(Integer.parseInt(txtFinalPaperl.getText().trim()));	
						e.setMarksFinalPaperRepeat(Integer.parseInt(txtFinalPaperlR.getText().trim()));	
						
						if(course.getHasPracticals())
						{
							e.setMarksPractical(Integer.parseInt(txtPractical.getText().trim()));
							e.setMarksPracticalRepeat(Integer.parseInt(txtPracticalR.getText().trim()));
						}
						else
						{
							e.setMarksPractical(ProgramUitl.MIN_MARKS);
							e.setMarksPracticalRepeat(ProgramUitl.MIN_MARKS);
						}

						//Set to Zero
						e.setMarksInterimReport(ProgramUitl.MIN_MARKS);	
						e.setMarksInterimReportRepeat(ProgramUitl.MIN_MARKS);	
						
						e.setMarksInterimPresentation(ProgramUitl.MIN_MARKS);	
						e.setMarksInterimPresentationRepeat(ProgramUitl.MIN_MARKS);	
												
						e.setMarksFinalReport(ProgramUitl.MIN_MARKS);	
						e.setMarksFinalReportRepeat(ProgramUitl.MIN_MARKS);	
						
						e.setMarksFinalPresentation(ProgramUitl.MIN_MARKS);	
						e.setMarksFinalPresentationRepeat(ProgramUitl.MIN_MARKS);	
						
						e.setMarksFinalProduct(ProgramUitl.MIN_MARKS);	
						e.setMarksFinalProductRepeat(ProgramUitl.MIN_MARKS);					
												
					break;
					case OPTIONAL:
						e.setMarksAssignment1(Integer.parseInt(txtAssignment1.getText().trim()));
						e.setMarksAssignment1Repeat(Integer.parseInt(txtAssignment1R.getText().trim()));
						
						e.setMarksAssignment2(Integer.parseInt(txtAssignment2.getText().trim()));
						e.setMarksAssignment2Repeat(Integer.parseInt(txtAssignment2R.getText().trim()));
						
						e.setMarksClassTest(Integer.parseInt(txtClassTest.getText().trim()));
						e.setMarksClassTestRepeat(Integer.parseInt(txtClassTestR.getText().trim()));
						
						e.setMarksFinalPaper(Integer.parseInt(txtFinalPaperl.getText().trim()));	
						e.setMarksFinalPaperRepeat(Integer.parseInt(txtFinalPaperlR.getText().trim()));	
						
						if(course.getHasPracticals())
						{
							e.setMarksPractical(Integer.parseInt(txtPractical.getText().trim()));
							e.setMarksPracticalRepeat(Integer.parseInt(txtPracticalR.getText().trim()));
						}
						else
						{
							e.setMarksPractical(ProgramUitl.MIN_MARKS);
							e.setMarksPracticalRepeat(ProgramUitl.MIN_MARKS);
						}

						//Set to Zero
												
						e.setMarksAssignment3(ProgramUitl.MIN_MARKS);
						e.setMarksAssignment3Repeat(ProgramUitl.MIN_MARKS);
						
						e.setMarksInterimReport(ProgramUitl.MIN_MARKS);	
						e.setMarksInterimReportRepeat(ProgramUitl.MIN_MARKS);	
						
						e.setMarksInterimPresentation(ProgramUitl.MIN_MARKS);	
						e.setMarksInterimPresentationRepeat(ProgramUitl.MIN_MARKS);	
												
						e.setMarksFinalReport(ProgramUitl.MIN_MARKS);	
						e.setMarksFinalReportRepeat(ProgramUitl.MIN_MARKS);	
						
						e.setMarksFinalPresentation(ProgramUitl.MIN_MARKS);	
						e.setMarksFinalPresentationRepeat(ProgramUitl.MIN_MARKS);	
						
						e.setMarksFinalProduct(ProgramUitl.MIN_MARKS);	
						e.setMarksFinalProductRepeat(ProgramUitl.MIN_MARKS);	
						
						//				
					break;
					case PROJECT:											
						e.setMarksInterimReport(Integer.parseInt(txtProjectIReport.getText().trim()));	
						e.setMarksInterimReportRepeat(Integer.parseInt(txtProjectIReportR.getText().trim()));	
						
						e.setMarksInterimPresentation(Integer.parseInt(txtProjectIPresentation.getText().trim()));	
						e.setMarksInterimPresentationRepeat(Integer.parseInt(txtProjectIPresentationR.getText().trim()));	
												
						e.setMarksFinalReport(Integer.parseInt(txtProjectFReport.getText().trim()));	
						e.setMarksFinalReportRepeat(Integer.parseInt(txtProjectFReportR.getText().trim()));	
						
						e.setMarksFinalPresentation(Integer.parseInt(txtProjectFPresentation.getText().trim()));	
						e.setMarksFinalPresentationRepeat(Integer.parseInt(txtProjectFPresentationR.getText().trim()));	
						
						e.setMarksFinalProduct(Integer.parseInt(txtProjectFProd.getText().trim()));	
						e.setMarksFinalProductRepeat(Integer.parseInt(txtProjectFProdR.getText().trim()));						
						
						//Set to Zero
						e.setMarksAssignment1(ProgramUitl.MIN_MARKS);
						e.setMarksAssignment1Repeat(ProgramUitl.MIN_MARKS);
						
						e.setMarksAssignment2(ProgramUitl.MIN_MARKS);
						e.setMarksAssignment2Repeat(ProgramUitl.MIN_MARKS);
						
						e.setMarksAssignment3(ProgramUitl.MIN_MARKS);
						e.setMarksAssignment3Repeat(ProgramUitl.MIN_MARKS);
						
						e.setMarksClassTest(ProgramUitl.MIN_MARKS);
						e.setMarksClassTestRepeat(ProgramUitl.MIN_MARKS);
						
						e.setMarksFinalPaper(ProgramUitl.MIN_MARKS);	
						e.setMarksFinalPaperRepeat(ProgramUitl.MIN_MARKS);							
						
						e.setMarksPractical(ProgramUitl.MIN_MARKS);
						e.setMarksPracticalRepeat(ProgramUitl.MIN_MARKS);							
						//
					break;			
				}
				e.setFinalMark((float)Calculations.getInstance().calculateFinalMark(e));
				e.setFGrade(Calculations.getInstance().calculateFinalGrade(e));				
				e.setFinalGP((float)Calculations.getInstance().calculateFinalGP(e));	
				
				if(XmlOperations.getInstance().updateEnroll(e))
				{
					JOptionPane.showMessageDialog(null,ProgramUitl.UPDATE_STUDENT_MARKS_TEXT+ProgramUitl.SCCUESS,ProgramUitl.UPDATE_STUDENT_MARKS_TEXT,JOptionPane.INFORMATION_MESSAGE);
					exit();
				}
				else
				{
					JOptionPane.showMessageDialog(null,ProgramUitl.UPDATE_STUDENT_MARKS_TEXT+ProgramUitl.FAILED,ProgramUitl.UPDATE_STUDENT_MARKS_TEXT,JOptionPane.ERROR_MESSAGE);
				}
				e=null;
				System.gc();
			}
		}
	}
	void clearText()
	{
		//http://stackoverflow.com/questions/3314183/how-to-access-controls-on-a-jpanel
		if(Confirmation( ProgramUitl.MARKS_CONFRIM_TO_CLEAR_TEXT))
		{
			Component c = null;
			Component[] components = screenSub.getComponents();
			if(components != null)
			{
				int numComponents = components.length;
				for(int i = 0; i < numComponents; i++)
				{
					c = components[i];
					if(c != null)
					{
						if(c instanceof JTextField)
						{
							((JTextField)c).setText(Integer.toString(ProgramUitl.MIN_MARKS));
						}
					}
				}
			}
		}
	}
	boolean Confirmation(String txt)
	{
		int confirmed = JOptionPane.showConfirmDialog(null, 
				txt, ProgramUitl.UPDATE_STUDENT_MARKS_TEXT, 
				JOptionPane.YES_NO_OPTION); 
				
		return confirmed == JOptionPane.YES_OPTION;
	}
	
	public boolean isValidInputs(Course c)
	{
		String msg="";

		
		switch(c.getType())
		{
			case CORE:
				
				if( ProgramUitl.isPositiveWithNumeric(txtAssignment1.getText().trim()))
				{
					if(Integer.parseInt(txtAssignment1.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblAssignment1.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblAssignment1.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
				
				if( ProgramUitl.isPositiveWithNumeric(txtAssignment2.getText().trim()))
				{
					if(Integer.parseInt(txtAssignment2.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblAssignment2.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblAssignment2.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
				
				if( ProgramUitl.isPositiveWithNumeric(txtAssignment3.getText().trim()))
				{
					if(Integer.parseInt(txtAssignment3.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblAssignment3.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblAssignment3.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}

				if( ProgramUitl.isPositiveWithNumeric(txtClassTest.getText().trim()))
				{
					if(Integer.parseInt(txtClassTest.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblClassTest.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblClassTest.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
				
				if(c.getHasPracticals())
				{
					if( ProgramUitl.isPositiveWithNumeric(txtPractical.getText().trim()))
					{
						if(Integer.parseInt(txtPractical.getText().trim()) > ProgramUitl.MAX_MARKS)
						{
							msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblPractical.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
						}
						
					}
					else
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblPractical.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}		
				}				
	
				if( ProgramUitl.isPositiveWithNumeric(txtFinalPaperl.getText().trim()))
				{
					if(Integer.parseInt(txtFinalPaperl.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblFinalPaperl.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblFinalPaperl.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}		

				
				//Repeat
				if( ProgramUitl.isPositiveWithNumeric(txtAssignment1R.getText().trim()))
				{
					if(Integer.parseInt(txtAssignment1R.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblAssignment1R.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblAssignment1R.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}

				if( ProgramUitl.isPositiveWithNumeric(txtAssignment2R.getText().trim()))
				{
					if(Integer.parseInt(txtAssignment2R.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblAssignment2R.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblAssignment2R.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}

				
				if( ProgramUitl.isPositiveWithNumeric(txtAssignment3R.getText().trim()))
				{
					if(Integer.parseInt(txtAssignment3R.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblAssignment3R.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblAssignment3R.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}

				if( ProgramUitl.isPositiveWithNumeric(txtClassTestR.getText().trim()))
				{
					if(Integer.parseInt(txtClassTestR.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblClassTestR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblClassTestR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
						
				if(c.getHasPracticals())
				{
					if( ProgramUitl.isPositiveWithNumeric(txtPracticalR.getText().trim()))
					{
						if(Integer.parseInt(txtPracticalR.getText().trim()) > ProgramUitl.MAX_MARKS)
						{
							msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblPracticalR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
						}
						
					}
					else
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblPracticalR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
	
				}				
		
				if( ProgramUitl.isPositiveWithNumeric(txtFinalPaperlR.getText().trim()))
				{
					if(Integer.parseInt(txtFinalPaperlR.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblFinalPaperlR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblFinalPaperlR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}						
				//
			break;
			case OPTIONAL:
				if( ProgramUitl.isPositiveWithNumeric(txtAssignment1.getText().trim()))
				{
					if(Integer.parseInt(txtAssignment1.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblAssignment1.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblAssignment1.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
				
				if( ProgramUitl.isPositiveWithNumeric(txtAssignment2.getText().trim()))
				{
					if(Integer.parseInt(txtAssignment2.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblAssignment2.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblAssignment2.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
				

				if( ProgramUitl.isPositiveWithNumeric(txtClassTest.getText().trim()))
				{
					if(Integer.parseInt(txtClassTest.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblClassTest.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblClassTest.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
								
				if(c.getHasPracticals())
				{
					if( ProgramUitl.isPositiveWithNumeric(txtPractical.getText().trim()))
					{
						if(Integer.parseInt(txtPractical.getText().trim()) > ProgramUitl.MAX_MARKS)
						{
							msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblPractical.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
						}
						
					}
					else
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblPractical.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}		
				}				
	
				if( ProgramUitl.isPositiveWithNumeric(txtFinalPaperl.getText().trim()))
				{
					if(Integer.parseInt(txtFinalPaperl.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblFinalPaperl.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblFinalPaperl.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}		

				
				//Repeat
				if( ProgramUitl.isPositiveWithNumeric(txtAssignment1R.getText().trim()))
				{
					if(Integer.parseInt(txtAssignment1R.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblAssignment1R.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblAssignment1R.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}

				if( ProgramUitl.isPositiveWithNumeric(txtAssignment2R.getText().trim()))
				{
					if(Integer.parseInt(txtAssignment2R.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblAssignment2R.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblAssignment2R.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}

				if( ProgramUitl.isPositiveWithNumeric(txtClassTestR.getText().trim()))
				{
					if(Integer.parseInt(txtClassTestR.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblClassTestR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblClassTestR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
						
				if(c.getHasPracticals())
				{
					if( ProgramUitl.isPositiveWithNumeric(txtPracticalR.getText().trim()))
					{
						if(Integer.parseInt(txtPracticalR.getText().trim()) > ProgramUitl.MAX_MARKS)
						{
							msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblPracticalR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
						}
						
					}
					else
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblPracticalR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
	
				}				
		
				if( ProgramUitl.isPositiveWithNumeric(txtFinalPaperlR.getText().trim()))
				{
					if(Integer.parseInt(txtFinalPaperlR.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblFinalPaperlR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblFinalPaperlR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}						
				//				
			break;
			case PROJECT:
					
				if( ProgramUitl.isPositiveWithNumeric(txtProjectIReport.getText().trim()))
				{					
					if(Integer.parseInt(txtProjectIReport.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblProjectIReport.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblProjectIReport.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
				
				if( ProgramUitl.isPositiveWithNumeric(txtProjectIPresentation.getText().trim()))
				{
					if(Integer.parseInt(txtProjectIPresentation.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblProjectIPresentation.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblProjectIPresentation.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
				
				if( ProgramUitl.isPositiveWithNumeric(txtProjectFReport.getText().trim()))
				{
					if(Integer.parseInt(txtProjectFReport.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblProjectFReport.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblProjectFReport.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}

				if( ProgramUitl.isPositiveWithNumeric(txtProjectFPresentation.getText().trim()))
				{
					if(Integer.parseInt(txtProjectFPresentation.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblProjectFPresentation.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblProjectFPresentation.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}

				if( ProgramUitl.isPositiveWithNumeric(txtProjectFProd.getText().trim()))
				{
					if(Integer.parseInt(txtProjectFProd.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblProjectFProd.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_NORMAL_TEXT+"]"+lblProjectFProd.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}				
				
				if( ProgramUitl.isPositiveWithNumeric(txtProjectIReportR.getText().trim()))
				{
					if(Integer.parseInt(txtProjectIReportR.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblProjectIReportR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblProjectIReportR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
				
				if( ProgramUitl.isPositiveWithNumeric(txtProjectIPresentationR.getText().trim()))
				{
					if(Integer.parseInt(txtProjectIPresentationR.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblProjectIPresentationR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblProjectIPresentationR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
				
				if( ProgramUitl.isPositiveWithNumeric(txtProjectFReportR.getText().trim()))
				{
					if(Integer.parseInt(txtProjectFReportR.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblProjectFReportR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblProjectFReportR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}

				if( ProgramUitl.isPositiveWithNumeric(txtProjectFPresentationR.getText().trim()))
				{
					if(Integer.parseInt(txtProjectFPresentationR.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblProjectFPresentationR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblProjectFPresentationR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}

				if( ProgramUitl.isPositiveWithNumeric(txtProjectFProdR.getText().trim()))
				{
					if(Integer.parseInt(txtProjectFProdR.getText().trim()) > ProgramUitl.MAX_MARKS)
					{
						msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblProjectFProdR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
					}
					
				}
				else
				{
					msg+=ProgramUitl.buildMessageItem("["+ProgramUitl.MARK_REPEAT_TEXT+"]"+lblProjectFProdR.getText().trim() + ProgramUitl.INVALID_FORMAT_ERROR);
				}
				//
			break;			
		}
		
		if(ProgramUitl.IsEmptyString(msg)!=true)
		{
			JOptionPane.showMessageDialog(null,msg,ProgramUitl.UPDATE_STUDENT_MARKS_TEXT,JOptionPane.ERROR_MESSAGE);
		}
		

		return ProgramUitl.IsEmptyString(msg);			
            	
	}
	
	
	//Events
	public void actionPerformed(ActionEvent ae)
	{
		if(ae.getSource().equals(btnExit))
		{
			exit();
		}	
		else if(ae.getSource().equals(btnAdd))
		{		
			addMarks();
		}
		else if(ae.getSource().equals(btnClear))
		{			
			clearText();			
		}		
	}	
	//	
}